﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1._29_设计模式.简单工厂.计算器._1
{
    class opration
    {
        public string a;
        public string c;

        public virtual string get_result() {
            return "没有实现";
        }
    }

    class add :opration {
        public override string get_result()
        {
            return (int.Parse(a)+int.Parse(c)).ToString();
        }
    }

    class sub : opration
    {
        public override string get_result()
        {
            return (int.Parse(a) - int.Parse(c)).ToString();
        }
    }

    class mul : opration
    {
        public override string get_result()
        {
            return (int.Parse(a) * int.Parse(c)).ToString();
        }
    }

    class div : opration
    {
        public override string get_result()
        {
            return (int.Parse(a) / int.Parse(c)).ToString();
        }
    }

    class factory {
        public static opration create(string b) {
            switch (b)
            {
                case "+":
                    return new add();
                    break;
                case "-":
                    return new sub();
                    break;
                case "*":
                    return new mul();
                    break;
                case "/":
                    return new div();
                    break;
                default:
                    return new opration();
                    break;
            }
        }
    }


    class Class4
    {
        public static void main()
        {

            Console.WriteLine("please insert A");
            string a = Console.ReadLine();

            Console.WriteLine("please insert simble");
            string b = Console.ReadLine();

            Console.WriteLine("please insert B");
            string c = Console.ReadLine();

            //Console.WriteLine(oprationg.work(a,b,c));

            opration o= factory.create(b);
            o.a = a;
            o.c = c;
            Console.WriteLine(o.get_result());
            //switch (b)
            //{
            //    case "+":
            //        Console.WriteLine(int.Parse(a) + int.Parse(c));
            //        break;
            //    case "-":
            //        Console.WriteLine(int.Parse(a) - int.Parse(c));
            //        break;
            //    case "*":
            //        Console.WriteLine(int.Parse(a) * int.Parse(c));
            //        break;
            //    case "/":
            //        Console.WriteLine(int.Parse(a) / int.Parse(c));
            //        break;
            //}

            //if (b == "+") 
            //{
            //    Console.WriteLine(int.Parse(a) + int.Parse(c));
            //}
            //if (b == "-")
            //{
            //    Console.WriteLine(int.Parse(a) - int.Parse(c));
            //}
            //if (b == "*")
            //{
            //    Console.WriteLine(int.Parse(a) * int.Parse(c));
            //}
            //if (b == "/")
            //{
            //    Console.WriteLine(int.Parse(a) / int.Parse(c));
            //}

            Console.ReadLine();
        }




    }
}
